package test.simple;

import org.apache.camel.CamelContext;
import org.apache.camel.Exchange;
import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.impl.DefaultCamelContext;


//http://camel.apache.org/timer.html
//http://camel.apache.org/log.html
//http://camel.apache.org/jetty.html
//http://camel.apache.org/expression.html
//http://camel.apache.org/simple.html


public class LaunchTimerHttpRequest {

	/**
	 * @param args
	 */
	public static void main(String[] args) throws Exception{
		// TODO Auto-generated method stub
		// TODO Auto-generated method stub
		CamelContext context = new DefaultCamelContext();
		context.addRoutes(new RouteBuilder() {
			public void configure() {
				
				from("jetty:http://localhost:8976/test").to("log:org.apache.camel.example?level=INFO&showAll=true&multiline=true");
			}
		});
		context.addRoutes(new RouteBuilder() {
			public void configure() {
				
				from("timer:period=2000").setHeader(Exchange.HTTP_METHOD, constant("POST")).transform().simple("Test date ${date:now:yyyy-MM-dd'T'HH:mm:ss:SSS}").to("http://localhost:8976/test");
			}
		});
		
		context.start();
		Thread.sleep(50000);
		context.stop();
	}

}
